// Using the IPCListPorts function to obtain a list of ports // Assuming Inclusion of MacHeaders
#include <PPCToolBox.h>
#include <Script.h>
// include string.h for strcpy function
#include < string.h>
// Prototype your function like this prior to calling it
OSErr MyIPCListPorts( short theStartIndex, short theRequestCount, short *theActualCount,
PortInfoArrayPtr thePortInfoBufferPtr )
{
// list all PPC ports at the specified location
thePPCPortRec.nameScript = smRoman;
// set name to match all names, NOTE call to CtoPstr to convert string
// back to Pascal style string.
strcpy((char *)thePPCPortRec.name,"=");
CtoPstr(thePPCPortRec.name);
thePPCPortRec.portKindSelector = ppcByString;
// match all types, NOTE call to CtoPstr to convert string
// back to pascal style string after casting for call to strcpy
strcpy((char *)thePPCPortRec.u.portTypeStr,"=");
CtoPstr(thePPCPortRec.u.portTypeStr);
// The application must choose and supply the NBP zone string from
// the list returned by GetZoneList. Then, the application must // choose and supply the NBP object string from the list returned by
// NBPLookup. This example looks for NBP type "PPC Example". If you // don't supply your own NBP type, you should use "PPCToolBox" for
// the NBP type string.
theLocationNameRec. locationKindSelector = ppcNBPLocation;
// copy objstr, note casting to make C type string for strcpy
// then convert string back to pascal type string
strcpy ((char *) theLocationNameRec.u.nbpEntity.objStr,
(char *)theObjStr);
CtoPstr( theLocationNameRec.u.nbpEntity.objStr);
// copy typestr, note casting to make C type string for strcpy
// then convert string back to pascal type string
strcpy((char *) theLocationNameRec.u.nbpEntity.typeStr,"PPC Example");
CtoPstr( theLocationNameRec.u.nbpEntity.typeStr);
// copy zonestr, note casting to make C type string for strcpy
// then convert string back to pascal type string
strcpy((char *) theLocationNameRec.u.nbpEntity.zoneStr, (char *)theZoneStr);
CtoPstr( theLocationNameRec.u.nbpEntity.zoneStr); theIPCListPortsPBRec.requestCount = theRequestCount;
theIPCListPortsPBRec.portName = &thePPCPortRec;
theIPCListPortsPBRec. locationName = & theLocationNameRec;
theIPCListPortsPBRec. bufferPtr = thePortInfoBufferPtr;
*theActualCount = theIPCListPortsPBRec.actualCount;
return err;
}